package com.moxiao.yfjh.module.blind.dal.mysql.member;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.moxiao.yfjh.framework.common.pojo.PageResult;
import com.moxiao.yfjh.framework.mybatis.core.mapper.BaseMapperX;
import com.moxiao.yfjh.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.moxiao.yfjh.module.blind.controller.admin.member.vo.AppTeamReqVo;
import com.moxiao.yfjh.module.blind.controller.admin.member.vo.BlindMemberUserExportReqVO;
import com.moxiao.yfjh.module.blind.controller.admin.member.vo.BlindMemberUserPageReqVO;
import com.moxiao.yfjh.module.blind.controller.admin.member.vo.BlindMemberUserRespVO;
import com.moxiao.yfjh.module.blind.controller.app.controller.user.vo.AppBlindUserPageReqVO;
import com.moxiao.yfjh.module.blind.dal.dataobject.comment.MemberCommentDO;
import com.moxiao.yfjh.module.blind.dal.dataobject.member.BlindMemberUserDO;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;

/**
 * 相亲会员用户 Mapper
 *
 * @author mx
 */
@Mapper
public interface BlindMemberUserMapper extends BaseMapperX<BlindMemberUserDO> {

    default PageResult<BlindMemberUserDO> selectPage(BlindMemberUserPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BlindMemberUserDO>()
                .eqIfPresent(BlindMemberUserDO::getNo, reqVO.getNo())
                .eqIfPresent(BlindMemberUserDO::getUserNo, reqVO.getUserNo())
                .eqIfPresent(BlindMemberUserDO::getUserLevel, reqVO.getUserLevel())
                .eqIfPresent(BlindMemberUserDO::getUsers, reqVO.getUsers())
                .eqIfPresent(BlindMemberUserDO::getMobile, reqVO.getMobile())
                .eqIfPresent(BlindMemberUserDO::getPassword, reqVO.getPassword())
                .eqIfPresent(BlindMemberUserDO::getDistributors, reqVO.getDistributors())
                .eqIfPresent(BlindMemberUserDO::getPesence, reqVO.getPesence())
                .eqIfPresent(BlindMemberUserDO::getStatus, reqVO.getStatus())
                .eqIfPresent(BlindMemberUserDO::getRegisterIp, reqVO.getRegisterIp())
                .eqIfPresent(BlindMemberUserDO::getLoginIp, reqVO.getLoginIp())
                .betweenIfPresent(BlindMemberUserDO::getLoginDate, reqVO.getLoginDate())
                .eqIfPresent(BlindMemberUserDO::getSex, reqVO.getSex())
                .eqIfPresent(BlindMemberUserDO::getAreaId, reqVO.getAreaId())
                .eqIfPresent(BlindMemberUserDO::getBirthday, reqVO.getBirthday())
                .eqIfPresent(BlindMemberUserDO::getHeight, reqVO.getHeight())
                .eqIfPresent(BlindMemberUserDO::getWeight, reqVO.getWeight())
                .eqIfPresent(BlindMemberUserDO::getEducation, reqVO.getEducation())
                .eqIfPresent(BlindMemberUserDO::getMarriage, reqVO.getMarriage())
                .eqIfPresent(BlindMemberUserDO::getMonthIncome, reqVO.getMonthIncome())
                .likeIfPresent(BlindMemberUserDO::getNickname, reqVO.getNickname())
                .eqIfPresent(BlindMemberUserDO::getAvatar, reqVO.getAvatar())
                .likeIfPresent(BlindMemberUserDO::getName, reqVO.getName())
                .eqIfPresent(BlindMemberUserDO::getIdNumber, reqVO.getIdNumber())
                .eqIfPresent(BlindMemberUserDO::getInnerMonologue, reqVO.getInnerMonologue())
                .eqIfPresent(BlindMemberUserDO::getCareer, reqVO.getCareer())
                .eqIfPresent(BlindMemberUserDO::getNativePlace, reqVO.getNativePlace())
                .eqIfPresent(BlindMemberUserDO::getPurchasHouse, reqVO.getPurchasHouse())
                .eqIfPresent(BlindMemberUserDO::getPurchasCar, reqVO.getPurchasCar())
                .eqIfPresent(BlindMemberUserDO::getWithChild, reqVO.getWithChild())
                .eqIfPresent(BlindMemberUserDO::getWantChild, reqVO.getWantChild())
                .betweenIfPresent(BlindMemberUserDO::getMarryDate, reqVO.getMarryDate())
                .eqIfPresent(BlindMemberUserDO::getSmoker, reqVO.getSmoker())
                .eqIfPresent(BlindMemberUserDO::getDrink, reqVO.getDrink())
                .eqIfPresent(BlindMemberUserDO::getHaveMember, reqVO.getHaveMember())
                .betweenIfPresent(BlindMemberUserDO::getMemberBeginTime, reqVO.getMemberBeginTime())
                .betweenIfPresent(BlindMemberUserDO::getMemberEndTime, reqVO.getMemberEndTime())
                .eqIfPresent(BlindMemberUserDO::getNation, reqVO.getNation())
                .eqIfPresent(BlindMemberUserDO::getConstellation, reqVO.getConstellation())
                .eqIfPresent(BlindMemberUserDO::getMatchAge, reqVO.getMatchAge())
                .eqIfPresent(BlindMemberUserDO::getMatchHeight, reqVO.getMatchHeight())
                .eqIfPresent(BlindMemberUserDO::getMatchIncome, reqVO.getMatchIncome())
                .eqIfPresent(BlindMemberUserDO::getMatchEducation, reqVO.getMatchEducation())
                .eqIfPresent(BlindMemberUserDO::getMatchMarriage, reqVO.getMatchMarriage())
                .eqIfPresent(BlindMemberUserDO::getMatchWorkArea, reqVO.getMatchWorkArea())
                .eqIfPresent(BlindMemberUserDO::getMatchWithChild, reqVO.getMatchWithChild())
                .eqIfPresent(BlindMemberUserDO::getMatchWantChild, reqVO.getMatchWantChild())
                .eqIfPresent(BlindMemberUserDO::getMatchSmoker, reqVO.getMatchSmoker())
                .eqIfPresent(BlindMemberUserDO::getMatchDrink, reqVO.getMatchDrink())
                .eqIfPresent(BlindMemberUserDO::getAuditStatus, reqVO.getAuditStatus())
                .eqIfPresent(BlindMemberUserDO::getAuitUser, reqVO.getAuitUser())
                .betweenIfPresent(BlindMemberUserDO::getAuitTime, reqVO.getAuitTime())
                .eqIfPresent(BlindMemberUserDO::getRejectReason, reqVO.getRejectReason())
                .betweenIfPresent(BlindMemberUserDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BlindMemberUserDO::getId));
    }

    default PageResult<BlindMemberUserDO> avatarReviewList(BlindMemberUserPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BlindMemberUserDO>()
                .eqIfPresent(BlindMemberUserDO::getNo, reqVO.getNo())
                .eqIfPresent(BlindMemberUserDO::getUserNo, reqVO.getUserNo())
                .eqIfPresent(BlindMemberUserDO::getUserLevel, reqVO.getUserLevel())
                .eqIfPresent(BlindMemberUserDO::getUsers, reqVO.getUsers())
                .eqIfPresent(BlindMemberUserDO::getMobile, reqVO.getMobile())
                .eqIfPresent(BlindMemberUserDO::getPassword, reqVO.getPassword())
                .eqIfPresent(BlindMemberUserDO::getDistributors, reqVO.getDistributors())
                .eqIfPresent(BlindMemberUserDO::getPesence, reqVO.getPesence())
                .eqIfPresent(BlindMemberUserDO::getStatus, reqVO.getStatus())
                .eqIfPresent(BlindMemberUserDO::getRegisterIp, reqVO.getRegisterIp())
                .eqIfPresent(BlindMemberUserDO::getLoginIp, reqVO.getLoginIp())
                .betweenIfPresent(BlindMemberUserDO::getLoginDate, reqVO.getLoginDate())
                .eqIfPresent(BlindMemberUserDO::getSex, reqVO.getSex())
                .eqIfPresent(BlindMemberUserDO::getAreaId, reqVO.getAreaId())
                .eqIfPresent(BlindMemberUserDO::getBirthday, reqVO.getBirthday())
                .eqIfPresent(BlindMemberUserDO::getHeight, reqVO.getHeight())
                .eqIfPresent(BlindMemberUserDO::getWeight, reqVO.getWeight())
                .eqIfPresent(BlindMemberUserDO::getEducation, reqVO.getEducation())
                .eqIfPresent(BlindMemberUserDO::getMarriage, reqVO.getMarriage())
                .eqIfPresent(BlindMemberUserDO::getMonthIncome, reqVO.getMonthIncome())
                .likeIfPresent(BlindMemberUserDO::getNickname, reqVO.getNickname())
                .eqIfPresent(BlindMemberUserDO::getAvatar, reqVO.getAvatar())
                .likeIfPresent(BlindMemberUserDO::getName, reqVO.getName())
                .eqIfPresent(BlindMemberUserDO::getIdNumber, reqVO.getIdNumber())
                .eqIfPresent(BlindMemberUserDO::getInnerMonologue, reqVO.getInnerMonologue())
                .eqIfPresent(BlindMemberUserDO::getCareer, reqVO.getCareer())
                .eqIfPresent(BlindMemberUserDO::getNativePlace, reqVO.getNativePlace())
                .eqIfPresent(BlindMemberUserDO::getPurchasHouse, reqVO.getPurchasHouse())
                .eqIfPresent(BlindMemberUserDO::getPurchasCar, reqVO.getPurchasCar())
                .eqIfPresent(BlindMemberUserDO::getWithChild, reqVO.getWithChild())
                .eqIfPresent(BlindMemberUserDO::getWantChild, reqVO.getWantChild())
                .betweenIfPresent(BlindMemberUserDO::getMarryDate, reqVO.getMarryDate())
                .eqIfPresent(BlindMemberUserDO::getSmoker, reqVO.getSmoker())
                .eqIfPresent(BlindMemberUserDO::getDrink, reqVO.getDrink())
                .eqIfPresent(BlindMemberUserDO::getHaveMember, reqVO.getHaveMember())
                .betweenIfPresent(BlindMemberUserDO::getMemberBeginTime, reqVO.getMemberBeginTime())
                .betweenIfPresent(BlindMemberUserDO::getMemberEndTime, reqVO.getMemberEndTime())
                .eqIfPresent(BlindMemberUserDO::getNation, reqVO.getNation())
                .eqIfPresent(BlindMemberUserDO::getConstellation, reqVO.getConstellation())
                .eqIfPresent(BlindMemberUserDO::getMatchAge, reqVO.getMatchAge())
                .eqIfPresent(BlindMemberUserDO::getMatchHeight, reqVO.getMatchHeight())
                .eqIfPresent(BlindMemberUserDO::getMatchIncome, reqVO.getMatchIncome())
                .eqIfPresent(BlindMemberUserDO::getMatchEducation, reqVO.getMatchEducation())
                .eqIfPresent(BlindMemberUserDO::getMatchMarriage, reqVO.getMatchMarriage())
                .eqIfPresent(BlindMemberUserDO::getMatchWorkArea, reqVO.getMatchWorkArea())
                .eqIfPresent(BlindMemberUserDO::getMatchWithChild, reqVO.getMatchWithChild())
                .eqIfPresent(BlindMemberUserDO::getMatchWantChild, reqVO.getMatchWantChild())
                .eqIfPresent(BlindMemberUserDO::getMatchSmoker, reqVO.getMatchSmoker())
                .eqIfPresent(BlindMemberUserDO::getMatchDrink, reqVO.getMatchDrink())
                .eqIfPresent(BlindMemberUserDO::getAuditStatus, reqVO.getAuditStatus())
                .eqIfPresent(BlindMemberUserDO::getAuitUser, reqVO.getAuitUser())
                .betweenIfPresent(BlindMemberUserDO::getAuitTime, reqVO.getAuitTime())
                .eqIfPresent(BlindMemberUserDO::getRejectReason, reqVO.getRejectReason())
                .betweenIfPresent(BlindMemberUserDO::getCreateTime, reqVO.getCreateTime())
                .orderByAsc(BlindMemberUserDO::getAuditStatus).orderByDesc(BlindMemberUserDO::getCreateTime));
    }


    default List<BlindMemberUserDO> selectList(BlindMemberUserExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<BlindMemberUserDO>()
                .eqIfPresent(BlindMemberUserDO::getNo, reqVO.getNo())
                .eqIfPresent(BlindMemberUserDO::getUserNo, reqVO.getUserNo())
                .eqIfPresent(BlindMemberUserDO::getUserLevel, reqVO.getUserLevel())
                .eqIfPresent(BlindMemberUserDO::getUsers, reqVO.getUsers())
                .eqIfPresent(BlindMemberUserDO::getMobile, reqVO.getMobile())
                .eqIfPresent(BlindMemberUserDO::getPassword, reqVO.getPassword())
                .eqIfPresent(BlindMemberUserDO::getDistributors, reqVO.getDistributors())
                .eqIfPresent(BlindMemberUserDO::getPesence, reqVO.getPesence())
                .eqIfPresent(BlindMemberUserDO::getStatus, reqVO.getStatus())
                .eqIfPresent(BlindMemberUserDO::getRegisterIp, reqVO.getRegisterIp())
                .eqIfPresent(BlindMemberUserDO::getLoginIp, reqVO.getLoginIp())
                .betweenIfPresent(BlindMemberUserDO::getLoginDate, reqVO.getLoginDate())
                .eqIfPresent(BlindMemberUserDO::getSex, reqVO.getSex())
                .eqIfPresent(BlindMemberUserDO::getAreaId, reqVO.getAreaId())
                .eqIfPresent(BlindMemberUserDO::getBirthday, reqVO.getBirthday())
                .eqIfPresent(BlindMemberUserDO::getHeight, reqVO.getHeight())
                .eqIfPresent(BlindMemberUserDO::getWeight, reqVO.getWeight())
                .eqIfPresent(BlindMemberUserDO::getEducation, reqVO.getEducation())
                .eqIfPresent(BlindMemberUserDO::getMarriage, reqVO.getMarriage())
                .eqIfPresent(BlindMemberUserDO::getMonthIncome, reqVO.getMonthIncome())
                .likeIfPresent(BlindMemberUserDO::getNickname, reqVO.getNickname())
                .eqIfPresent(BlindMemberUserDO::getAvatar, reqVO.getAvatar())
                .likeIfPresent(BlindMemberUserDO::getName, reqVO.getName())
                .eqIfPresent(BlindMemberUserDO::getIdNumber, reqVO.getIdNumber())
                .eqIfPresent(BlindMemberUserDO::getInnerMonologue, reqVO.getInnerMonologue())
                .eqIfPresent(BlindMemberUserDO::getCareer, reqVO.getCareer())
                .eqIfPresent(BlindMemberUserDO::getNativePlace, reqVO.getNativePlace())
                .eqIfPresent(BlindMemberUserDO::getPurchasHouse, reqVO.getPurchasHouse())
                .eqIfPresent(BlindMemberUserDO::getPurchasCar, reqVO.getPurchasCar())
                .eqIfPresent(BlindMemberUserDO::getWithChild, reqVO.getWithChild())
                .eqIfPresent(BlindMemberUserDO::getWantChild, reqVO.getWantChild())
                .betweenIfPresent(BlindMemberUserDO::getMarryDate, reqVO.getMarryDate())
                .eqIfPresent(BlindMemberUserDO::getSmoker, reqVO.getSmoker())
                .eqIfPresent(BlindMemberUserDO::getDrink, reqVO.getDrink())
                .eqIfPresent(BlindMemberUserDO::getHaveMember, reqVO.getHaveMember())
                .betweenIfPresent(BlindMemberUserDO::getMemberBeginTime, reqVO.getMemberBeginTime())
                .betweenIfPresent(BlindMemberUserDO::getMemberEndTime, reqVO.getMemberEndTime())
                .eqIfPresent(BlindMemberUserDO::getNation, reqVO.getNation())
                .eqIfPresent(BlindMemberUserDO::getConstellation, reqVO.getConstellation())
                .eqIfPresent(BlindMemberUserDO::getMatchAge, reqVO.getMatchAge())
                .eqIfPresent(BlindMemberUserDO::getMatchHeight, reqVO.getMatchHeight())
                .eqIfPresent(BlindMemberUserDO::getMatchIncome, reqVO.getMatchIncome())
                .eqIfPresent(BlindMemberUserDO::getMatchEducation, reqVO.getMatchEducation())
                .eqIfPresent(BlindMemberUserDO::getMatchMarriage, reqVO.getMatchMarriage())
                .eqIfPresent(BlindMemberUserDO::getMatchWorkArea, reqVO.getMatchWorkArea())
                .eqIfPresent(BlindMemberUserDO::getMatchWithChild, reqVO.getMatchWithChild())
                .eqIfPresent(BlindMemberUserDO::getMatchWantChild, reqVO.getMatchWantChild())
                .eqIfPresent(BlindMemberUserDO::getMatchSmoker, reqVO.getMatchSmoker())
                .eqIfPresent(BlindMemberUserDO::getMatchDrink, reqVO.getMatchDrink())
                .eqIfPresent(BlindMemberUserDO::getAuditStatus, reqVO.getAuditStatus())
                .eqIfPresent(BlindMemberUserDO::getAuitUser, reqVO.getAuitUser())
                .betweenIfPresent(BlindMemberUserDO::getAuitTime, reqVO.getAuitTime())
                .eqIfPresent(BlindMemberUserDO::getRejectReason, reqVO.getRejectReason())
                .betweenIfPresent(BlindMemberUserDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BlindMemberUserDO::getId));
    }

    @Select("select count(*) num from blind_member_user where user_no = #{userNo}")
    Integer getMemberUserNo(@Param("userNo") String userNo);


    @Select("select count(*) num from blind_member_user")
    Integer getMemberUserNum();


    default PageResult<BlindMemberUserDO> selectBasicList(AppBlindUserPageReqVO pageVO) {
        return selectPage(pageVO, new LambdaQueryWrapperX<BlindMemberUserDO>()
                .likeIfPresent(BlindMemberUserDO::getAreaId,pageVO.getAreaId())
                .likeIfPresent(BlindMemberUserDO::getMobile,pageVO.getMobile())
                .betweenIfPresent(BlindMemberUserDO::getAge, pageVO.getAgeMix(),pageVO.getAgeMax())
                .eq(BlindMemberUserDO::getSex, pageVO.getSex())
                .ne(BlindMemberUserDO::getId,pageVO.getId())
                .isNotNull(BlindMemberUserDO::getAvatar)
                .orderByDesc(BlindMemberUserDO::getId));
    }

    default Long selectBasicCount(AppBlindUserPageReqVO pageVO) {
        return selectCount(
                new LambdaQueryWrapperX<BlindMemberUserDO>()
                .likeIfPresent(BlindMemberUserDO::getAreaId,pageVO.getAreaId())
                .likeIfPresent(BlindMemberUserDO::getMobile,pageVO.getMobile())
                .betweenIfPresent(BlindMemberUserDO::getAge, pageVO.getAgeMix(),pageVO.getAgeMax())
                .eq(BlindMemberUserDO::getSex, pageVO.getSex())
                .ne(BlindMemberUserDO::getId,pageVO.getId())
                .isNotNull(BlindMemberUserDO::getAvatar));
    }



    /**
     * 择偶条件匹配
     * @param reqVO
     * @return
     */
    default List<BlindMemberUserDO> selectSingleList(AppBlindUserPageReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<BlindMemberUserDO>()
                .betweenIfPresent(BlindMemberUserDO::getAge,reqVO.getAgeMix(),reqVO.getAgeMax())
                .betweenIfPresent(BlindMemberUserDO::getHeight, reqVO.getHeightMix(),reqVO.getHeightMax())
                .eqIfPresent(BlindMemberUserDO::getMonthIncome, reqVO.getMonthIncome())
                .eqIfPresent(BlindMemberUserDO::getEducation, reqVO.getEducation())
                .eqIfPresent(BlindMemberUserDO::getMarriage, reqVO.getMarriage())
                .likeIfPresent(BlindMemberUserDO::getAreaId, reqVO.getAreaId())
                .eqIfPresent(BlindMemberUserDO::getWithChild, reqVO.getWithChild())
                .eqIfPresent(BlindMemberUserDO::getWantChild, reqVO.getWantChild())
                .eqIfPresent(BlindMemberUserDO::getSmoker, reqVO.getSmoker())
                .eqIfPresent(BlindMemberUserDO::getDrink, reqVO.getDrink())
                .isNotNull(BlindMemberUserDO::getAvatar)
                .ne(BlindMemberUserDO::getId,reqVO.getId())
                .notLike(BlindMemberUserDO::getSex,reqVO.getSex())
                .orderByDesc(BlindMemberUserDO::getId));
    }



    /**
     * 自身条件匹配
     * @param reqVO
     * @return
     */
    default Long selectMyConditionsCount(AppBlindUserPageReqVO reqVO) {

        LambdaQueryWrapperX<BlindMemberUserDO> blindMemberUserDOLambdaQueryWrapperX = new LambdaQueryWrapperX<BlindMemberUserDO>();
        blindMemberUserDOLambdaQueryWrapperX.betweenIfPresent(BlindMemberUserDO::getMatchAge,reqVO.getAgeMix(),reqVO.getAgeMax());
        blindMemberUserDOLambdaQueryWrapperX.betweenIfPresent(BlindMemberUserDO::getMatchHeight, reqVO.getHeightMix(),reqVO.getHeightMax());
        if(StringUtils.isNotEmpty(reqVO.getMatchIncome())) {
            blindMemberUserDOLambdaQueryWrapperX.or(wrapper -> wrapper.eq(StringUtils.isNotEmpty(reqVO.getMonthIncome()), BlindMemberUserDO::getMonthIncome, reqVO.getMonthIncome())
                    .or()
                    .eq(StringUtils.isNotEmpty(reqVO.getMonthIncome()), BlindMemberUserDO::getMonthIncome, "0"));

        }

        if(StringUtils.isNotEmpty(reqVO.getEducation())) {
            blindMemberUserDOLambdaQueryWrapperX.or(wrapper -> wrapper.eq(StringUtils.isNotEmpty(reqVO.getEducation()), BlindMemberUserDO::getMatchEducation, reqVO.getEducation())
                    .or()
                    .eq(StringUtils.isNotEmpty(reqVO.getEducation()), BlindMemberUserDO::getMatchEducation, "0"));

        }
        if(StringUtils.isNotEmpty(reqVO.getMarriage())) {
            blindMemberUserDOLambdaQueryWrapperX.or(wrapper -> wrapper.eq(StringUtils.isNotEmpty(reqVO.getMarriage()), BlindMemberUserDO::getMatchMarriage, reqVO.getMarriage())
                    .or()
                    .eq(StringUtils.isNotEmpty(reqVO.getMarriage()), BlindMemberUserDO::getMatchMarriage, "0"));

        }

        if(StringUtils.isNotEmpty(reqVO.getAreaId())) {
            blindMemberUserDOLambdaQueryWrapperX.or(wrapper -> wrapper.eq(StringUtils.isNotEmpty(reqVO.getAreaId()), BlindMemberUserDO::getMatchWorkArea, reqVO.getAreaId())
                    .or()
                    .eq(StringUtils.isNotEmpty(reqVO.getAreaId()), BlindMemberUserDO::getMatchWorkArea, "0"));

        }

        if(StringUtils.isNotEmpty(reqVO.getAreaId())) {
            blindMemberUserDOLambdaQueryWrapperX.or(wrapper -> wrapper.like(StringUtils.isNotEmpty(reqVO.getAreaId()), BlindMemberUserDO::getMatchWorkArea, reqVO.getAreaId())
                    .or()
                    .like(StringUtils.isNotEmpty(reqVO.getAreaId()), BlindMemberUserDO::getMatchWorkArea, "0"));

        }

        if(Objects.nonNull(reqVO.getWithChild())) {
            blindMemberUserDOLambdaQueryWrapperX.or(wrapper -> wrapper.eq(Objects.nonNull(reqVO.getWithChild()), BlindMemberUserDO::getMatchWithChild, reqVO.getWithChild())
                    .or()
                    .eq(Objects.nonNull(reqVO.getWithChild()), BlindMemberUserDO::getMatchWithChild, "0"));
        }

        if(Objects.nonNull(reqVO.getWantChild())) {
            blindMemberUserDOLambdaQueryWrapperX.or(wrapper -> wrapper.eq(Objects.nonNull(reqVO.getWantChild()), BlindMemberUserDO::getMatchWantChild, reqVO.getWantChild())
                    .or()
                    .eq(Objects.nonNull(reqVO.getWantChild()), BlindMemberUserDO::getMatchWantChild, "0"));
        }

        if(Objects.nonNull(reqVO.getSmoker())) {
            blindMemberUserDOLambdaQueryWrapperX.or(wrapper -> wrapper.eq(Objects.nonNull(reqVO.getSmoker()), BlindMemberUserDO::getMatchSmoker, reqVO.getSmoker())
                    .or()
                    .eq(Objects.nonNull(reqVO.getSmoker()), BlindMemberUserDO::getMatchSmoker, "0"));
        }

        if(Objects.nonNull(reqVO.getDrink())) {
            blindMemberUserDOLambdaQueryWrapperX.or(wrapper -> wrapper.eq(Objects.nonNull(reqVO.getDrink()), BlindMemberUserDO::getMatchDrink, reqVO.getDrink())
                    .or()
                    .eq(Objects.nonNull(reqVO.getDrink()), BlindMemberUserDO::getMatchDrink, "0"));
        }

        blindMemberUserDOLambdaQueryWrapperX.isNotNull(BlindMemberUserDO::getAvatar);
        blindMemberUserDOLambdaQueryWrapperX.ne(BlindMemberUserDO::getId,reqVO.getId());
        blindMemberUserDOLambdaQueryWrapperX.notLike(BlindMemberUserDO::getSex,reqVO.getSex());
        blindMemberUserDOLambdaQueryWrapperX.orderByDesc(BlindMemberUserDO::getId);
        return selectCount(blindMemberUserDOLambdaQueryWrapperX);
    }
    /**
     * 自身条件匹配
     * @param reqVO
     * @return
     */
    default PageResult<BlindMemberUserDO> selectMyConditionsList(AppBlindUserPageReqVO reqVO) {

        LambdaQueryWrapperX<BlindMemberUserDO> blindMemberUserDOLambdaQueryWrapperX = new LambdaQueryWrapperX<BlindMemberUserDO>();
        blindMemberUserDOLambdaQueryWrapperX.betweenIfPresent(BlindMemberUserDO::getMatchAge,reqVO.getAgeMix(),reqVO.getAgeMax());
        blindMemberUserDOLambdaQueryWrapperX.betweenIfPresent(BlindMemberUserDO::getMatchHeight, reqVO.getHeightMix(),reqVO.getHeightMax());
        if(StringUtils.isNotEmpty(reqVO.getMatchIncome())) {
            blindMemberUserDOLambdaQueryWrapperX.or(wrapper -> wrapper.eq(StringUtils.isNotEmpty(reqVO.getMonthIncome()), BlindMemberUserDO::getMonthIncome, reqVO.getMonthIncome())
                    .or()
                    .eq(StringUtils.isNotEmpty(reqVO.getMonthIncome()), BlindMemberUserDO::getMonthIncome, "0"));

        }

        if(StringUtils.isNotEmpty(reqVO.getEducation())) {
            blindMemberUserDOLambdaQueryWrapperX.or(wrapper -> wrapper.eq(StringUtils.isNotEmpty(reqVO.getEducation()), BlindMemberUserDO::getMatchEducation, reqVO.getEducation())
                    .or()
                    .eq(StringUtils.isNotEmpty(reqVO.getEducation()), BlindMemberUserDO::getMatchEducation, "0"));

        }
        if(StringUtils.isNotEmpty(reqVO.getMarriage())) {
            blindMemberUserDOLambdaQueryWrapperX.or(wrapper -> wrapper.eq(StringUtils.isNotEmpty(reqVO.getMarriage()), BlindMemberUserDO::getMatchMarriage, reqVO.getMarriage())
                    .or()
                    .eq(StringUtils.isNotEmpty(reqVO.getMarriage()), BlindMemberUserDO::getMatchMarriage, "0"));

        }

        if(StringUtils.isNotEmpty(reqVO.getAreaId())) {
            blindMemberUserDOLambdaQueryWrapperX.or(wrapper -> wrapper.eq(StringUtils.isNotEmpty(reqVO.getAreaId()), BlindMemberUserDO::getMatchWorkArea, reqVO.getAreaId())
                    .or()
                    .eq(StringUtils.isNotEmpty(reqVO.getAreaId()), BlindMemberUserDO::getMatchWorkArea, "0"));

        }

        if(StringUtils.isNotEmpty(reqVO.getAreaId())) {
            blindMemberUserDOLambdaQueryWrapperX.or(wrapper -> wrapper.like(StringUtils.isNotEmpty(reqVO.getAreaId()), BlindMemberUserDO::getMatchWorkArea, reqVO.getAreaId())
                    .or()
                    .like(StringUtils.isNotEmpty(reqVO.getAreaId()), BlindMemberUserDO::getMatchWorkArea, "0"));

        }

        if(Objects.nonNull(reqVO.getWithChild())) {
            blindMemberUserDOLambdaQueryWrapperX.or(wrapper -> wrapper.eq(Objects.nonNull(reqVO.getWithChild()), BlindMemberUserDO::getMatchWithChild, reqVO.getWithChild())
                    .or()
                    .eq(Objects.nonNull(reqVO.getWithChild()), BlindMemberUserDO::getMatchWithChild, "0"));
        }

        if(Objects.nonNull(reqVO.getWantChild())) {
            blindMemberUserDOLambdaQueryWrapperX.or(wrapper -> wrapper.eq(Objects.nonNull(reqVO.getWantChild()), BlindMemberUserDO::getMatchWantChild, reqVO.getWantChild())
                    .or()
                    .eq(Objects.nonNull(reqVO.getWantChild()), BlindMemberUserDO::getMatchWantChild, "0"));
        }

        if(Objects.nonNull(reqVO.getSmoker())) {
            blindMemberUserDOLambdaQueryWrapperX.or(wrapper -> wrapper.eq(Objects.nonNull(reqVO.getSmoker()), BlindMemberUserDO::getMatchSmoker, reqVO.getSmoker())
                    .or()
                    .eq(Objects.nonNull(reqVO.getSmoker()), BlindMemberUserDO::getMatchSmoker, "0"));
        }

        if(Objects.nonNull(reqVO.getDrink())) {
            blindMemberUserDOLambdaQueryWrapperX.or(wrapper -> wrapper.eq(Objects.nonNull(reqVO.getDrink()), BlindMemberUserDO::getMatchDrink, reqVO.getDrink())
                    .or()
                    .eq(Objects.nonNull(reqVO.getDrink()), BlindMemberUserDO::getMatchDrink, "0"));
        }

        blindMemberUserDOLambdaQueryWrapperX.isNotNull(BlindMemberUserDO::getAvatar);
        blindMemberUserDOLambdaQueryWrapperX.ne(BlindMemberUserDO::getId,reqVO.getId());
        blindMemberUserDOLambdaQueryWrapperX.notLike(BlindMemberUserDO::getSex,reqVO.getSex());
        blindMemberUserDOLambdaQueryWrapperX.orderByDesc(BlindMemberUserDO::getId);
        return selectPage(reqVO,blindMemberUserDOLambdaQueryWrapperX);
    }


    /**
     * 搜索匹配
     * @param reqVO
     * @return
     */
    default PageResult<BlindMemberUserDO> searchMemberPage(AppBlindUserPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BlindMemberUserDO>()
                .betweenIfPresent(BlindMemberUserDO::getAge,reqVO.getAgeMix(),reqVO.getAgeMax())
                .betweenIfPresent(BlindMemberUserDO::getHeight,reqVO.getHeightMix(),reqVO.getHeightMax())
                .eqIfPresent(BlindMemberUserDO::getMonthIncome, reqVO.getMonthIncome())
                .eqIfPresent(BlindMemberUserDO::getNo, reqVO.getNo())
                .eqIfPresent(BlindMemberUserDO::getUserNo, reqVO.getUserNo())
                .eqIfPresent(BlindMemberUserDO::getUserLevel, reqVO.getUserLevel())
                .eqIfPresent(BlindMemberUserDO::getUsers, reqVO.getUsers())
                .eqIfPresent(BlindMemberUserDO::getMobile, reqVO.getMobile())
                .eqIfPresent(BlindMemberUserDO::getPassword, reqVO.getPassword())
                .eqIfPresent(BlindMemberUserDO::getDistributors, reqVO.getDistributors())
                .eqIfPresent(BlindMemberUserDO::getPesence, reqVO.getPesence())
                .eqIfPresent(BlindMemberUserDO::getStatus, reqVO.getStatus())
                .eqIfPresent(BlindMemberUserDO::getRegisterIp, reqVO.getRegisterIp())
                .eqIfPresent(BlindMemberUserDO::getLoginIp, reqVO.getLoginIp())
                .betweenIfPresent(BlindMemberUserDO::getLoginDate, reqVO.getLoginDate())
                .eqIfPresent(BlindMemberUserDO::getSex, reqVO.getSex())
                .eqIfPresent(BlindMemberUserDO::getAreaId, reqVO.getAreaId())
                .eqIfPresent(BlindMemberUserDO::getBirthday, reqVO.getBirthday())
                .eqIfPresent(BlindMemberUserDO::getWeight, reqVO.getWeight())
                .eqIfPresent(BlindMemberUserDO::getEducation, reqVO.getEducation())
                .eqIfPresent(BlindMemberUserDO::getMarriage, reqVO.getMarriage())
                .likeIfPresent(BlindMemberUserDO::getNickname, reqVO.getNickname())
                .eqIfPresent(BlindMemberUserDO::getAvatar, reqVO.getAvatar())
                .likeIfPresent(BlindMemberUserDO::getName, reqVO.getName())
                .eqIfPresent(BlindMemberUserDO::getIdNumber, reqVO.getIdNumber())
                .eqIfPresent(BlindMemberUserDO::getInnerMonologue, reqVO.getInnerMonologue())
                .eqIfPresent(BlindMemberUserDO::getCareer, reqVO.getCareer())
                .eqIfPresent(BlindMemberUserDO::getNativePlace, reqVO.getNativePlace())
                .eqIfPresent(BlindMemberUserDO::getPurchasHouse, reqVO.getPurchasHouse())
                .eqIfPresent(BlindMemberUserDO::getPurchasCar, reqVO.getPurchasCar())
                .eqIfPresent(BlindMemberUserDO::getWithChild, reqVO.getWithChild())
                .eqIfPresent(BlindMemberUserDO::getWantChild, reqVO.getWantChild())
                .betweenIfPresent(BlindMemberUserDO::getMarryDate, reqVO.getMarryDate())
                .eqIfPresent(BlindMemberUserDO::getSmoker, reqVO.getSmoker())
                .eqIfPresent(BlindMemberUserDO::getDrink, reqVO.getDrink())
                .eqIfPresent(BlindMemberUserDO::getHaveMember, reqVO.getHaveMember())
                .eqIfPresent(BlindMemberUserDO::getHaveReal,reqVO.getHaveReal())
                .betweenIfPresent(BlindMemberUserDO::getMemberBeginTime, reqVO.getMemberBeginTime())
                .betweenIfPresent(BlindMemberUserDO::getMemberEndTime, reqVO.getMemberEndTime())
                .eqIfPresent(BlindMemberUserDO::getNation, reqVO.getNation())
                .eqIfPresent(BlindMemberUserDO::getConstellation, reqVO.getConstellation())
                .eqIfPresent(BlindMemberUserDO::getMatchAge, reqVO.getMatchAge())
                .eqIfPresent(BlindMemberUserDO::getMatchHeight, reqVO.getMatchHeight())
                .eqIfPresent(BlindMemberUserDO::getMatchIncome, reqVO.getMatchIncome())
                .eqIfPresent(BlindMemberUserDO::getMatchEducation, reqVO.getMatchEducation())
                .eqIfPresent(BlindMemberUserDO::getMatchMarriage, reqVO.getMatchMarriage())
                .eqIfPresent(BlindMemberUserDO::getMatchWorkArea, reqVO.getMatchWorkArea())
                .eqIfPresent(BlindMemberUserDO::getMatchWithChild, reqVO.getMatchWithChild())
                .eqIfPresent(BlindMemberUserDO::getMatchWantChild, reqVO.getMatchWantChild())
                .eqIfPresent(BlindMemberUserDO::getMatchSmoker, reqVO.getMatchSmoker())
                .eqIfPresent(BlindMemberUserDO::getMatchDrink, reqVO.getMatchDrink())
                .eqIfPresent(BlindMemberUserDO::getAuditStatus, reqVO.getAuditStatus())
                .eqIfPresent(BlindMemberUserDO::getAuitUser, reqVO.getAuitUser())
                .betweenIfPresent(BlindMemberUserDO::getAuitTime, reqVO.getAuitTime())
                .eqIfPresent(BlindMemberUserDO::getRejectReason, reqVO.getRejectReason())
                .betweenIfPresent(BlindMemberUserDO::getCreateTime, reqVO.getCreateTime())
                .isNotNull(BlindMemberUserDO::getAvatar)
                .orderByDesc(BlindMemberUserDO::getId));
    }


    /**
     * 通过分销员来查询分销员的下属团队
     */
    @Select(" SELECT t.id user_id,t.nickname,t.avatar,t.create_time,t1.price as commission" +
            " FROM blind_member_user t" +
            " LEFT JOIN blind_brokerage_record t1 on t1.source_user_id = t.id" +
            " WHERE distributors = #{distributors}")
    List<AppTeamReqVo> getTeamList(@Param("distributors") String distributors);

    /**
     * 关联分页查询
     * 分销员
     */
    IPage<BlindMemberUserRespVO> getDistributorsList(Page<?> page, @Param("mobile") String mobile, @Param("nickname") String nickname);

    /**
     * 获得团队人数
     *
     * @param userId
     * @return
     */
    @Select("select count(*) from blind_member_user where distributors = #{userId}")
    Integer getTeam(@Param("userId") String userId);

    /**
     * 分页-团队列表
     */
    @Select("select t.* " +
            " from blind_member_user t" +
            " where t.distributors = #{userId}")
    IPage<BlindMemberUserRespVO> getPageTeamList(@Param("userId") String userId);

    /**
     * 分销员累计业绩
     */
    @Select("select IFNULL(sum(t.pay_price),0.00) pay_price" +
            " from blind_trade_order t" +
            " JOIN blind_member_user t1 on t.user_id = t1.id" +
            " where t1.distributors = #{userId}")
    BigDecimal getPerformance(@Param("userId") String userId);

    @Select("select count(*) from blind_merchant_info where name = #{name} and deleted=0 and status = 1")
    int getMerchantNum(@Param("name") String name);

    @Select("select count(*) from blind_member_user where nickname = #{nickname}")
    int getUserCount(@Param("nickname") String nickname);
}

